<?php

namespace App\Admin\Renderable;

use App\Models\Contact;
use App\Models\Title;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class ContactInfo extends LazyRenderable
{

    public function grid(): Grid
    {
        $id = $this->id;

        return Grid::make(new Contact(), function (Grid $grid) {
            $grid->column('id');
            $grid->column('name');
            $grid->column('phone', '电话号码');
            $grid->column('title', '职务')->display(function ($title) {
                return (Title::find($title))['name'];
            })->label(Admin::color()->info());
            $grid->column('note', '备注');
            $grid->column('updated_at')->sortable();

            $grid->quickSearch(['name', 'phone']);
            $grid->disableActions();
            $grid->paginate(10);
        });
    }
}
